package edu.pku.sei.transformation.editor.controller.commands.node;

import org.eclipse.gef.commands.Command;

import edu.pku.sei.transformation.editor.model.execution.Pin;
import edu.pku.sei.transformation.editor.model.execution.TransformationExecution;

public class PinCreateCommand extends Command {
	private Pin pin;
	private TransformationExecution te;

	public PinCreateCommand(Pin p, TransformationExecution te) {
		this.pin = p;
		this.te = te;
	}

	@Override
	public boolean canExecute() {
		if (pin == null || te == null)
			return false;
		return true;
	}

	@Override
	public void execute() {
		this.pin.setExecution(te);
		this.te.getActualParameters().add(pin);
	}

	@Override
	public void undo() {
		this.pin.setExecution(null);
		this.te.getActualParameters().remove(pin);
	}
}
